var hyischoiced=[];//已经选择的行业
var xqischoiced=[];//已经选择的兴趣
var alwaysnews=[];//已经选择的常看的新闻
var xqchoicenum=0;
var choicenum=0;//
var alwayschoicenum=0;
var hychoicenum=0;//行业
var pw;//密码
var sex=0;
var userAva; //保存头像名称
//var score="";
var allmychoicecityclick=0;//全局变量 点击的页面

//设置页返回
$("#mainsetpagegoback").click(function(){
    location.href="setpage.html"
});
//我常看的新闻返回
$("#alwaysseepagegoback").click(function(){
    $("#alwayschoicepage").css("display","none");
    $("#page_wrapper").css("display","block");
});
//我的行业返回
$("#myjobpagegoback").click(function(){
    $("#choicepage").css("display","none");
    $("#page_wrapper").css("display","block");
});
//我的兴趣返回
$("#hobbypagegoback").click(function(){
    $("#xqchoicepage").css("display","none");
    $("#page_wrapper").css("display","block");
});
//我的城市返回
//....
//我的学历返回
$("#edupagegoback").click(function(){
    $("#edchoicepage").css("display","none");
    $("#page_wrapper").css("display","block");
});

var he=window.screen.height-104;
$("#allcitypage").css("height",he);
//=========================删除已选择行业兴趣新闻===================================================================
function hydeletaspan(e){
    $(e).remove();
    e.className="tc_inner";
    $("#hychoicedbox span#"+e.id).remove();
    hychoicenum--;
}
function xqdeletaspan(e){
    $(e).remove();
    e.className="tc_inner";
    $("#xqchoicedbox span#"+e.id).remove();
    xqchoicenum--;
}
function aldeletaspan(e){
    $(e).remove();
    e.className="tc_inner";
    $("#alwayschoicedbox span#"+e.id).remove();
    alwayschoicenum--;
}
//var xquserdata;//已经选择的兴趣
//var hyuserdata;//已经选择的行业
//var xwuserdata;//已经选择的新闻

//裁剪图片坐标
var coordinateX=0,coordinateY=0,coordinateH=1,coordinateW= 1,cansendimg="yes";
//页面宽高
//var avaW=parseInt($("#page_wrapper").css("width"));
var avaW=parseInt(window.screen.availWidth);
if(avaW>1000){
    avaW=1000;
}
//var avaH=parseInt($("#page_wrapper").css("height"))-44;
var avaH=parseInt(window.screen.availHeight)-44;
//console.log(avaW+":"+avaH);
var jcropApi;//截取
var reader;//上传
var file;//上传文件
var submitData;

//function readFile(){
//    var img_area = document.getElementById("upload-img");
//    file = this.files[0];
//    if (!/image\/\w+/.test(file.type)) {
//        alert("image only please.");
//        return false;
//    }
//    reader = new FileReader();
//    reader.readAsDataURL(file);
//    reader.onload = function(e) {
//        //$("#sendimginfo").css("display","block");
//        imgresult=this.result;
//        submitData=this.result;
//
//        $("#page_wrapper").css("display","none");
//        $("#imgchoicepage").css("display","block");
//        $("#imgchoicepage img").attr("src",submitData);
//
//        $('#element_id').Jcrop({
//            allowResize:true, //不允许改变选中区域的大小
//            baseClass: 'jcrop',
//            minSize:[100,100],
//            setSelect:[0,0,avaW,avaW], //初始化选中区域
//            aspectRatio:1,
//            onSelect:function(d){
//                coordinateX=Math.round((d.x/avaW)*100)/100;
//                coordinateY=Math.round((d.y/avaH)*100)/100;
//                coordinateH=Math.round((d.h/avaH)*100)/100;
//                coordinateW=Math.round((d.w/avaW)*100)/100;
//                console.log(d);
//                console.log(coordinateX,coordinateY,coordinateH,coordinateW);
//            }
//        }, function() {
//            jcropApi = this;
//        });
//        //上传图片
//        $("#imgfinish").click(function(){
//            if(cansendimg=="yes"){
//                $("#sendimginfo").css("display","block");
//                cansendimg="no";
//                $.ajax({
//                    type: "POST",
//                    url: cutimgurl,
//                    data: {"base64":submitData,"type":".jpg","flag":1,"x":coordinateX,"y":coordinateY,"h":coordinateH,"w":coordinateW},
//                    dataType:"json",
//                    success: function(data){
//                        cansendimg="yes";
//                        userAva=data.Data;
//                        coordinateX=0;
//                        coordinateY=0;
//                        coordinateH=0;
//                        coordinateW=0;
//                        $("#sendimginfo").css("display","none");
//                        $("#imgchoicepage").css("display","none");
//                        $("#page_wrapper").css("display","block");
//                        img_area.innerHTML = '<img src="'+imgurl+data.Data+'" alt=""/>';
//                        jcropApi=null;
//                        reader=null;
//                        file=null;
//                        submitData=null;
//                    }
//                });
//            }
//        });
//    }
//}

//压缩上传图片方法↓ 涉及到裁剪头像==============================================================
function readFile(){
    var img_area = document.getElementById("upload-img");
    var file = this.files[0];
    //图片方向角 added by lzk
    var Orientation = null;
    var submitData;
    if (file) {
        console.log("正在压缩图片,请稍后...");
        //
        var rFilter = /^(image\/jpeg|image\/png)$/i; // 检查图片格式
        if (!rFilter.test(file.type)) {
            //showMyTips("请选择jpeg、png格式的图片", false);
            return;
        }
        // var URL = URL || webkitURL;
        //获取照片方向角属性，用户旋转控制
        EXIF.getData(file, function() {
            EXIF.getAllTags(this);
            Orientation = EXIF.getTag(this, 'Orientation');
        });

        var oReader = new FileReader();
        oReader.onload = function(e) {
            var image = new Image();
            image.src = e.target.result;
            submitData= e.target.result;
            console.log(submitData.length);
            image.onload = function() {
                var expectWidth = this.naturalWidth;
                var expectHeight = this.naturalHeight;

                if (this.naturalWidth > this.naturalHeight && this.naturalWidth > 400) {
                    expectWidth = 400;
                    expectHeight = expectWidth * this.naturalHeight / this.naturalWidth;
                } else if (this.naturalHeight > this.naturalWidth && this.naturalHeight > 400) {
                    expectHeight = 400;
                    expectWidth = expectHeight * this.naturalWidth / this.naturalHeight;
                }
                var canvas = document.createElement("canvas");
                var ctx = canvas.getContext("2d");
                canvas.width = expectWidth;
                canvas.height = expectHeight;
                ctx.drawImage(this, 0, 0, expectWidth, expectHeight);
                //var base64 =null;
                base64 = canvas.toDataURL("image/jpeg", 0.7);
                if(Orientation != "" && Orientation != 1){
                    var canvasRotateImage=new Image();
                    canvasRotateImage.src=base64;
                    canvasRotateImage.onload = function(){
                        switch(Orientation){
                            case 6://需要顺时针（向左）90度旋转
                                rotateImg(this,'left',canvas);
                                break;
                            case 8://需要逆时针（向右）90度旋转
                                rotateImg(this,'right',canvas);
                                break;
                            case 3://需要180度旋转
                                rotateImg(this,'right',canvas,2);//转两次
                                rotateImg(this,'right',canvas,2);
//                                    rotateImg(this,'right',canvas,2);//转两次
                                break;
                        }
                        base64 = canvas.toDataURL("image/jpeg", 0.7);

                    }
                }

                //压缩处理完成后 需要截取头像
                $("#page_wrapper").css("display","none");
                $("#imgchoicepage").css("display","block");
                $("#imgchoicepage img").attr("src",base64);
//                $('#element_id').Jcrop({
//                    allowResize:true, //不允许改变选中区域的大小
//                    baseClass: 'jcrop',
//                    minSize:[100,100],
//                    setSelect:[0,0,avaW,avaW], //初始化选中区域
//                    //setSelect:[0,0,100,100], //初始化选中区域
//                    aspectRatio:1,
//                    onSelect:function(d){
//                        console.log(d);
//                        //coordinateX=Math.round((d.x/expectWidth)*100)/100;
//                        //coordinateY=Math.round((d.y/expectHeight)*100)/100;
//                        //coordinateH=Math.round((d.h/expectHeight)*100)/100;
//                        //coordinateW=Math.round((d.w/expectWidth)*100)/100;
//                        coordinateX= (d.x/avaW)*expectWidth;
//                        coordinateY= (d.y/avaH)*expectHeight;
//                        coordinateH= (d.h/avaH)*expectHeight;
//                        coordinateW= (d.w/avaW)*expectWidth;
//                        //裁剪↓========================================================
//                        var cvs = document.createElement('canvas');
//                        //var img = $img[0];
//                        var img =new Image();
//                        img.src=base64;
//                        //var width = img.naturalWidth,
//                        //    height = img.naturalHeight;
//                        //cvs.width = width;
//                        //cvs.height = height;
//                        var width = expectWidth,
//                            height = expectHeight;
//                        cvs.width = width;
//                        cvs.height = height;
//                        var ctx = cvs.getContext("2d");
//                        var destX = 0,
//                            destY = 0;
//                        ctx.drawImage(img, destX, destY);
//                        //把选中框里的图片内容存起来
//                        var imageData ="";
//                        if(expectHeight>expectWidth){
//                            imageData = ctx.getImageData(0,(expectHeight-expectWidth)/2,expectWidth,expectWidth);
//                            cvs.width = expectWidth;
//                            cvs.height = expectWidth;
//                        }
//                        else if(expectHeight<expectWidth){
//                            imageData = ctx.getImageData((expectWidth-expectHeight)/2,0,expectHeight,expectHeight);
//                            cvs.width = expectHeight;
//                            cvs.height = expectHeight;
//                        }
//                        else{
//                            imageData = ctx.getImageData(0,0,expectWidth,expectWidth);
//                        }
//                        //console.log("原高度"+width+":"+height+";新高度"+coordinateW+":"+coordinateH);
//                        //console.log("截取参数"+coordinateX,coordinateY,coordinateW,coordinateH);
////然后再画上去
//                        ctx.putImageData(imageData, 0, 0);
//                        base64 = cvs.toDataURL("image/jpeg");
//                        //console.log(base64);
//                        //裁剪↑========================================================
//                    }
//                }, function() {
//                    jcropApi = this;
//                });
                //上传操作
                $("#imgfinish").click(function(){
                    if(cansendimg=="yes"){
                        $("#sendimginfo").css("display","block");
                        cansendimg="no";
                        $.ajax({
                            type: "POST",
                            //url: cutimgurl, //submitData
                            //data: {"base64":base64,"type":".jpg","flag":1,"x":coordinateX,"y":coordinateY,"h":coordinateH,"w":coordinateW},
                            url:  addimgurl,
                            data: { "base64":base64, "type": ".jpg","flag":1},//flag:1表示头像，2普通照片
                            dataType:"json",
                            success: function(data){
                                //if(data.Message){
                                //    alert("原图"+data.Message.length);
                                //}
                                base64=null;
                                file=null;
                                cansendimg="yes";
                                userAva=data.Data;
                                coordinateX=0;
                                coordinateY=0;
                                coordinateH=0;
                                coordinateW=0;
                                $("#sendimginfo").css("display","none");
                                $("#imgchoicepage").css("display","none");
                                $("#page_wrapper").css("display","block");
                                img_area.innerHTML = '<img src="'+imgurl+data.Data+'" alt=""/>';
                                jcropApi=null;
                                reader=null;
                                file=null;
                                submitData=null;
                            }
                        });
                    }
                });

            };
        };
        oReader.readAsDataURL(file);
    }
}
//对图片旋转处理
function rotateImg(img, direction,canvas,two) {
    //alert(img);
    //最小与最大旋转方向，图片旋转4次后回到原方向
    var min_step = 0;
    var max_step = 3;
    //var img = document.getElementById(pid);
    if (img == null)return;
    //img的高度和宽度不能在img元素隐藏后获取，否则会出错
    var height = img.height;
    var width = img.width;
    //var step = img.getAttribute('step');
    var step = 2;
    if(two==2){
        step=1;
    }
    if (step == null) {
        step = min_step;
    }
    if (direction == 'right') {
        step++;
        //旋转到原位置，即超过最大值
        step > max_step && (step = min_step);
    } else {
        step--;
        step < min_step && (step = max_step);
    }
    //img.setAttribute('step', step);
    /*var canvas = document.getElementById('pic_' + pid);
     if (canvas == null) {
     img.style.display = 'none';
     canvas = document.createElement('canvas');
     canvas.setAttribute('id', 'pic_' + pid);
     img.parentNode.appendChild(canvas);
     }  */
    //旋转角度以弧度值为参数
    //alert("执行");
    var degree = step * 90 * Math.PI / 180;
    var ctx = canvas.getContext('2d');
    switch (step) {
        case 0:
            canvas.width = width;
            canvas.height = height;
            ctx.drawImage(img, 0, 0);
            break;
        case 1:
            canvas.width = height;
            canvas.height = width;
            ctx.rotate(degree);
            ctx.drawImage(img, 0, -height);
            break;
        case 2:
            canvas.width = width;
            canvas.height = height;
            ctx.rotate(degree);
            ctx.drawImage(img, -width, -height);
            break;
        case 3:
            canvas.width = height;
            canvas.height = width;
            ctx.rotate(degree);
            ctx.drawImage(img, -width, 0);
            break;
    }
}
//压缩上传图片方法↑======================================================================================================
$("#closealertbtn").click(function(){
    $("#nokeywordalert").css("display","none");
});
//展示加载图片
function showloadimg(e){
    $(e).fadeIn();
}

//=================================================================================================
/*展开行业*/
function showProfessionPage(){
    professionList.style.display="block";
    page_wrapper.style.display="none";
    document.body.scrollTop = document.documentElement.scrollTop = 0;
}
/*选择展开排名*/
var choiceAdministration=false,choiceSkill=false;
function showAdministration(e){
    if(e.checked){
        administrationLi.style.display="block";
        choiceAdministration=true;
    }else{
        administrationLi.style.display="none";
        choiceAdministration=false;
    }
}
function showSkill(e){
    if(e.checked){
        skillLi.style.display="block";
        choiceSkill=true;
    }else{
        skillLi.style.display="none";
        choiceSkill=false;
    }
}
/*计算选择个数*/
var choiceProfessionNum=0;
var professionName=[];
function computeProfessiion(e){
    var labelClass= e.id.match(/\d+/)[0];
    var name=document.querySelector(".label"+ labelClass).innerHTML;
    if(e.checked){
        if(choiceProfessionNum>=3){e.checked=false;}
        else{
            choiceProfessionNum++;
            professionName.push(name);
        }
    }else{
        choiceProfessionNum--;
        for(var i=0;i<professionName.length;i++){
            if(professionName[i]==name){
                professionName.splice(i,1);
                break;
            }
        }
    }
    professionNum.innerHTML=choiceProfessionNum;
    var professionWord=professionName.join(",");
    document.querySelector(".professionDiv>.newsname").innerHTML=professionWord;
}
/*返回*/
function closeProfessionList(){
    professionList.style.display="none";
    page_wrapper.style.display="block";
}
/*确认*/
function choiceOkProfessionBtn(){
    professionList.style.display="none";
    page_wrapper.style.display="block";
    document.body.scrollTop = document.documentElement.scrollTop = 350;
}
//rankBack
$("#rankBack").click(function(){
    $("#register").css("display","block");
    $("#ranking").css("display","none");
});
//添加一个大范围
var largeNum=1;
function addLargeKeyWord(){
    $("#addLargeBtn").before('<div class="itemDiv large'+largeNum+'"> ' +
    '<div class="lf"> ' +
    '<span class="lf delBtn" onclick="delLarge('+largeNum+')">删除此项</span> ' +
    '<div style="margin-left:60px;padding-right:10px;"><input type="text" placeholder=""/></div>' +
    '</div> ' +
    '<div class="lf"> ' +
    '<span class="lf">排名：</span> ' +
    '<div><select name="level"> ' +
    '<option value="4">前10%</option> ' +
    '<option value="3">前11%-30%</option> ' +
    '<option value="2">前31%-60%</option> ' +
    '<option value="1">前61%-99%</option> ' +
    '</select></div> ' +
    '</div>'+
    '</div>');
    largeNum++;
}
//添加一个小范围
var smallNum=1;
function addSmallKeyWord(){
    $("#addSmallBtn").before('<div class="itemDiv small'+smallNum+'"> ' +
    '<div class="lf"> ' +
    '<span class="lf delBtn" onclick="delSmall('+smallNum+')">删除此项</span> ' +
    '<div style="margin-left:60px;padding-right:10px;"><input type="text" placeholder=""/></div> ' +
    '</div> ' +
    '<div class="lf"> ' +
    '<span class="lf">排名：</span> ' +
    '<div><select name="level"> ' +
    '<option value="4">前10%</option> ' +
    '<option value="3">前11%-30%</option> ' +
    '<option value="2">前31%-60%</option> ' +
    '<option value="1">前61%-99%</option> ' +
    '</select></div> ' +
    '</div>'+
    '</div>');
    smallNum++;
}
//删除一个大范围
function delLarge(n){$(".itemDiv.large"+n).remove();}
//删除一个小范围
function delSmall(n){$(".itemDiv.small"+n).remove();}
//验证排名信息
var TechParam=[];
function testRanking(){
    TechParam=[];
    var result=true;

    if(professionName.length==0||!$("#ranking .newsname").html()){
        //$("#rankErrorWord").html("请选择公司行业");
        $("#nokeywordalert").css("display","block");
        $("#nokeywordalert .word").html("请选择公司产业方向");
        result=false;
        return result;
    }
    if(!choiceAdministration&&!choiceSkill){
        //$("#rankErrorWord").html("请选择岗位");
        $("#nokeywordalert").css("display","block");
        $("#nokeywordalert .word").html("请选择职能级别");
        result=false;
        return result;
    }
    if(choiceSkill){
        //大领域
        var largeInput=$("div[class*='large'] input");
        var largeSelect=$("div[class*='large'] select");
        var len=largeInput.length;
        var haveLarge=false;
        for(var a=0;a<len;a++){
            var thisValue=largeInput[a].value.trim();
            //console.log(thisValue);
            if(thisValue){
                haveLarge=true;
                TechParam.push({
                    "keywordType":2,
                    "userId": $.cookie("MYID"),
                    "tecRank":parseInt(largeSelect[a].value),
                    "keyword":thisValue
                });
            }
        }
        if(!haveLarge){
            //$("#rankErrorWord").html("请填写大领域");
            $("#nokeywordalert").css("display","block");
            $("#nokeywordalert .word").html("请填写大领域关键词");
            result=false;
            return result;
        }
        else{
            var smallInput=$("div[class*='small'] input");
            var smallSelect=$("div[class*='small'] select");
            var leng=smallInput.length;
            var haveSmall=false;
            for(var b=0;b<leng;b++){
                var thisSmallValue=smallInput[b].value.trim();
                if(thisSmallValue){
                    TechParam.push({
                        "keywordType":1,
                        "userId": $.cookie("MYID"),
                        "tecRank":parseInt(smallSelect[b].value),
                        "keyword":thisSmallValue
                    });
                    haveSmall=true;
                }
            }
            if(!haveSmall){
                result=false;
                //$("#rankErrorWord").html("请填写小领域");
                $("#nokeywordalert").css("display","block");
                $("#nokeywordalert .word").html("请填写小领域关键词");
                return result;
            }
        }
    }
    return result;
};
$().ready(function(){
    var edokbtnimg2=document.getElementsByClassName("edokbtnimg2");//学历选中按钮图片2 没有选择
    var edokbtnimg1=document.getElementsByClassName("edokbtnimg1");//学历选中按钮图片1 选中
    //发送请求获取用户已有的信息
    $.ajax({
        type: "post",
        datatype: "json",
        url: userurl,
        data:{"loginuserId": id,"userId":id},
        success:function(data){
            $("#nick_name").val(data.Data.userNick);
            $("title").html("Pulu-"+data.Data.userNick+"-编辑");
            //if(data.Data.realName){$("#realname").val(data.Data.realName)};
            sex=data.Data.userSex;
            if(sex===1){
                $("#sexbox1").css("display","block");
                $("#sexbox2").css("display","none");
            }else if(sex===0){
                $("#sexbox1").css("display","none");
                $("#sexbox2").css("display","block");
            }
            //学历
            switch (data.Data.userEducation){
                case "初中及以下":
                    edokbtnimg2[0].style.display="none";
                    edokbtnimg1[0].style.display="block";
                    break;
                case "高中":
                    edokbtnimg2[1].style.display="none";
                    edokbtnimg1[1].style.display="block";
                    break;
                case "大学":
                    edokbtnimg2[2].style.display="none";
                    edokbtnimg1[2].style.display="block";
                    break;
                case "硕士及以上":
                    edokbtnimg2[3].style.display="none";
                    edokbtnimg1[3].style.display="block";
                    break;
            }
            $(".eduwords").html(data.Data.userEducation);
            //$("#education").val(data.Data.education);
            if(data.Data.visitedCity){
                var b=data.Data.visitedCity.match(/([\u4e00-\u9fa5]+)/g);
                for(var i5=0;i5<b.length;i5++){
                    $(".ctywords").append("<span>"+b[i5]+"</span>");
                }
            }
            //$("#choicedbox").append("<span id='"+event.target.id+"' onclick='hydeletaspan(this)'>"+event.target.innerHTML+"<a>×</a></span>");
            //行业兴趣新闻------------------------------

            //if(data.Data.jobs.length>3){
            //    hyuserdata=data.Data.jobs;
            //    hychoicenum=3;
            //    for(var i1=0;i1<3;i1++){
            //        $(".hangyewords").append("<span>"+data.Data.jobs[i1].typename+"</span>");
            //        hyischoiced.push({"id":data.Data.jobs[i1].id,"typename":data.Data.jobs[i1].typename});
            //        $("#choicedbox").append("<span id='"+data.Data.jobs[i1].id+"' onclick='hydeletaspan(this)'>"+data.Data.jobs[i1].typename+"<a>×</a></span>");
            //    }
            //}else if(data.Data.jobs.length>0&&data.Data.jobs.length<=3){
            //    hyuserdata=data.Data.jobs;
            //    hychoicenum=data.Data.jobs.length;
            //    for(var i2=0;i2<data.Data.jobs.length;i2++){
            //        $(".hangyewords").append("<span>"+data.Data.jobs[i2].typename+"</span>");
            //        hyischoiced.push({"id":data.Data.jobs[i2].id,"typename":data.Data.jobs[i2].typename});
            //        $("#choicedbox").append("<span id='"+data.Data.jobs[i2].id+"' onclick='hydeletaspan(this)'>"+data.Data.jobs[i2].typename+"<a>×</a></span>");
            //    }
            //}
            //if(data.Data.hobbys&&data.Data.hobbys.length>3){
            //    xquserdata=data.Data.hobbys;
            //    xqchoicenum=3;
            //    for(var i3=0;i3<3;i3++){
            //        $(".xingquwords").append("<span>"+data.Data.hobbys[i3].typename+"</span>");
            //        xqischoiced.push({"id":data.Data.hobbys[i3].id,"typename":data.Data.hobbys[i3].typename});
            //        $("#xqchoicedbox").append("<span id='"+data.Data.hobbys[i3].id+"' onclick='xqdeletaspan(this)'>"+data.Data.hobbys[i3].typename+"<a>×</a></span>");
            //    }
            //}else if(data.Data.hobbys.length>0&&data.Data.hobbys.length<=3){
            //    xquserdata=data.Data.hobbys;
            //    xqchoicenum=data.Data.hobbys.length;
            //    for(var i=0;i<data.Data.hobbys.length;i++){
            //        $(".xingquwords").append("<span>"+data.Data.hobbys[i].typename+"</span>");
            //        xqischoiced.push({"id":data.Data.hobbys[i].id,"typename":data.Data.hobbys[i].typename});
            //        $("#xqchoicedbox").append("<span id='"+data.Data.hobbys[i].id+"' onclick='xqdeletaspan(this)'>"+data.Data.hobbys[i].typename+"<a>×</a></span>");
            //    }
            //}
            //if(data.Data.news&&data.Data.news.length>3){
            //    xwuserdata=data.Data.news;
            //    alwayschoicenum=3;
            //    for(var i4=0;i4<3;i4++){
            //        $(".alwayswords").append("<span>"+data.Data.news[i4].typename+"</span>");
            //        alwaysnews.push({"id":data.Data.news[i4].id,"typename":data.Data.news[i4].typename});
            //        $("#alwayschoicedbox").append("<span id='"+data.Data.news[i4].id+"' onclick='aldeletaspan(this)'>"+data.Data.news[i4].typename+"<a>×</a></span>");
            //    }
            //}else if(data.Data.news.length>0&&data.Data.news.length<=3){
            //    xwuserdata=data.Data.news;
            //    alwayschoicenum=data.Data.news.length;
            //    for(var i=0;i<data.Data.news.length;i++){
            //        $(".alwayswords").append("<span>"+data.Data.news[i].typename+"</span>");
            //        alwaysnews.push({"id":data.Data.news[i].id,"typename":data.Data.news[i].typename});
            //        $("#alwayschoicedbox").append("<span id='"+data.Data.news[i].id+"' onclick='aldeletaspan(this)'>"+data.Data.news[i].typename+"<a>×</a></span>");
            //    }
            //}

            //$("#cities").val(data.Data.visitedcity);
            $("#mylabel").val(data.Data.userLabel);
            $("#personalword").val(data.Data.userSign);
            if(data.Data.locationCity&&data.Data.locationCity.length>0&&data.Data.locationCity!="null"){
                $(".myctywords").append("<span>"+data.Data.locationCity+"</span>");
            }
            if(data.Data.userAva){
                userAva=data.Data.userAva;
                img_area.innerHTML = '<img src="'+imgurl+data.Data.userAva+'" alt="" onload="showloadimg(this)" style="display:none;"/>'
            }else if(!data.Data.userAva){
                img_area.style.background="url(img/loseimg.png) no-repeact";
            }
            //公司行业
            if(data.Data.newJobs){
                $(".newsname").html(data.Data.newJobs);
                professionName=data.Data.newJobs.split(",");
                choiceProfessionNum=professionName.length;
                $("#professionNum").html(professionName.length);
                var allLabel=$("label");
                var bLen=allLabel.length;
                for(var a=0;a<professionName.length;a++){
                    for(var b=0;b<bLen;b++){
                        if(professionName[a]==allLabel[b].innerHTML){
                            var labelClass=allLabel[b].className.match(/[0-9]+/)[0];
                            $("#p"+labelClass).prop("checked",true);
                        }
                    }
                }
            }
            $("#companyRank").val(data.Data.companyRank);
            //职能级别
            if(data.Data.jobId){
                switch(data.Data.jobId){
                    case 1 :
                        $("#administrationState").prop("checked",true);
                        $("#administrationLi").css("display","block");
                        $("#skillLi").css("display","none");
                        console.log(data.Data.jobId);
                        choiceAdministration=true;
                        choiceSkill=false;
                        break;
                    case 2 :
                        $("#skillState").prop("checked",true);
                        choiceSkill=true;
                        choiceAdministration=false;
                        break;
                    case 3 :
                        $("#administrationState").prop("checked",true);
                        $("#skillState").prop("checked",true);
                        $("#administrationLi").css("display","block");
                        choiceAdministration=true;
                        choiceSkill=true;
                        break;
                }
            }
            //管理级别
            if(data.Data.manageRank){
                switch(data.Data.manageRank){
                    case 3 : $("#manageRank option:nth-child(1)").attr("selected",true);break;
                    case 2 : $("#manageRank option:nth-child(2)").attr("selected",true);break;
                    case 1 : $("#manageRank option:nth-child(3)").attr("selected",true);break;
                }
            }
            //领域
            if(data.Data.userTechKeyWords&&data.Data.userTechKeyWords.length>0){
                $("#skillLi").css("display","block");
                var tLength=data.Data.userTechKeyWords.length;
                var smallFirst=false,smallAllNum=0;
                var bigFirst=false,bigAllNum=0;
                for(var a=0;a<tLength;a++){
                    var oneSelect="";
                    var twoSelect="";
                    var threeSelect="";
                    var fourSelect="";
                    var firstSelect="";
                    switch(data.Data.userTechKeyWords[a].tecRank){
                        case 4 :fourSelect=' selected="selected"';firstSelect=1;break;
                        case 3 :threeSelect=' selected="selected"';firstSelect=2;break;
                        case 2 :twoSelect=' selected="selected"';firstSelect=3;break;
                        case 1 :oneSelect=' selected="selected"';firstSelect=4;break;
                    }
                    if(data.Data.userTechKeyWords[a].keywordType==1){
                        //小领域
                        smallAllNum++;
                        if(!smallFirst){
                            smallFirst=true;
                            $("#smallInput").val(data.Data.userTechKeyWords[a].keyword);
                            $("#smallLevel option:nth-child("+firstSelect+")").attr("selected",true);
                        }
                        else{
                            $("#addSmallBtn").before('<div class="itemDiv small'+smallAllNum+'"> ' +
                                '<div class="lf"> ' +
                                    '<span class="lf delBtn" onclick="delSmall('+smallAllNum+')">删除此项</span> ' +
                                    '<div style="margin-left:60px;padding-right:10px;"><input type="text" placeholder="" value="'+data.Data.userTechKeyWords[a].keyword+'"/></div> ' +
                                '</div> ' +
                                '<div class="lf"> ' +
                                    '<span class="lf">排名：</span> ' +
                                    '<div><select name="level"> ' +
                                    '<option value="4" '+fourSelect+'>前10%</option> ' +
                                    '<option value="3" '+threeSelect+'>前11%-30%</option> ' +
                                    '<option value="2" '+twoSelect+'>前31%-60%</option> ' +
                                    '<option value="1" '+oneSelect+'>前61%-99%</option> ' +
                                    '</select></div> ' +
                                '</div>'+
                            '</div>');
                        }
                    }
                    else if(data.Data.userTechKeyWords[a].keywordType==2){
                        //大领域
                        bigAllNum++;
                        if(!bigFirst){
                            bigFirst=true;
                            $("#largeInput").val(data.Data.userTechKeyWords[a].keyword);
                            $("#LargeLevel option:nth-child("+firstSelect+")").attr("selected",true);
                        }
                        else{
                            $("#addLargeBtn").before('<div class="itemDiv large'+bigAllNum+'"> ' +
                                '<div class="lf"> ' +
                                    '<span class="lf delBtn" onclick="delLarge('+bigAllNum+')">删除此项</span> ' +
                                    '<div style="margin-left:60px;padding-right:10px;"><input type="text" placeholder="" value="'+data.Data.userTechKeyWords[a].keyword+'"/></div>' +
                                '</div> ' +
                                '<div class="lf"> ' +
                                    '<span class="lf">排名：</span> ' +
                                    '<div><select name="level"> ' +
                                    '<option value="4" '+fourSelect+'>前10%</option> ' +
                                    '<option value="3" '+threeSelect+'>前11%-30%</option> ' +
                                    '<option value="2" '+twoSelect+'>前31%-60%</option> ' +
                                    '<option value="1" '+oneSelect+'>前61%-99%</option> ' +
                                    '</select></div> ' +
                                '</div>'+
                            '</div>');
                        }
                    }
                }
                smallNum=smallAllNum;
                largeNum=bigAllNum;
            }
        }
    });
    //最高学历
    document.getElementsByClassName("eudcationbtn")[0].onclick=function(){
        document.getElementById("edchoicepage").style.display="block";
        document.getElementById("page_wrapper").style.display="none";
    };
    //我的城市返回
    $("#citypagegoback").click(function(){
        mychoicecityclick=0;
        allmychoicecityclick=0;
        $("#ctchoicepage").css("display","none");
        $("#page_wrapper").css("display","block");
    });
    var edlist=document.getElementsByClassName("edlist");//学历列表
    var eduword="";
    for(var e=0;e<edlist.length;e++){
        edlist[e].index=e;
        edlist[e].onclick=function(event){
            if(edokbtnimg2[this.index].style.display==="none"){
                edokbtnimg2[this.index].style.display="block";
                edokbtnimg1[this.index].style.display="none";
                eduword="";
                $(".eduwords").html("");
                document.getElementById("edchoicepage").style.display="none";
                document.getElementById("page_wrapper").style.display="block";
            }else if(edokbtnimg2[this.index].style.display==="block"){
                for(var i=0;i<edlist.length;i++){
                    edokbtnimg2[i].style.display="block";
                    edokbtnimg1[i].style.display="none";
                    eduword="";
                }
                edokbtnimg2[this.index].style.display="none";
                edokbtnimg1[this.index].style.display="block";
                eduword=edlist[this.index].innerHTML.match(/([\u4E00-\u9FA5]+)/)[0];
                $(".eduwords").html(eduword);
                document.getElementById("edchoicepage").style.display="none";
                document.getElementById("page_wrapper").style.display="block";
            }
        }
    }
    document.getElementById("edfinish").onclick=function(){
        document.getElementById("edchoicepage").style.display="none";
        document.getElementById("page_wrapper").style.display="block";
    };
    //所在城市
    var mychoicecityclick=0;//当前点击的那个页面
    //所在城市
    $(".mychoicecitybtn").click(function(){
        $(".ctokbtnimg1").css("display","none");
        $(".ctokbtnimg2").css("display","none");
        $("#ctfinish").css("display","none");
        $("#page_wrapper").css("display","none");
        $("#ctchoicepage").css("display","block");
        $("#choicecitybox").css("display","none");
        $('#hotcity .ctlist .tc_inner').attr("class","tc_inner");
        if(document.querySelector(".kindword.myctywords span")){
            var mycityspan=document.querySelector(".kindword.myctywords span");
            var spanid=pinyin.getFullChars(mycityspan.innerHTML).toLowerCase();
            $('.tc_inner[data-id="'+spanid+'"]').attr("class","tc_inner clicked");
        }
        mychoicecityclick=1;
        allmychoicecityclick=1;
    });
    var choicenum=0;//城市已经选择的个数
    //待过的城市
    $(".choicecitybtn").click(function(){
        $("#choicecitybox span").remove();//城市列表中已经选择的城市
        $(".ctokbtnimg1").css("display","none");
        $(".ctokbtnimg2").css("display","block");
        $("#ctfinish").css("display","block");
        $('#hotcity .ctlist .tc_inner').attr("class","tc_inner");
        if(document.querySelectorAll(".kindword.ctywords span")){
            var mycityspan=document.querySelectorAll(".kindword.ctywords span");
            choicenum=mycityspan.length;
            for(var r= 0,l=mycityspan.length;r<l;r++){
                var spanid=pinyin.getFullChars(mycityspan[r].innerHTML).toLowerCase();
                $("#choicecitybox").append("<span id='s"+spanid+"'>"+mycityspan[r].innerHTML+"</span>");
                $("#"+spanid+" .ctokbtnimg2").css("display","none");
                $("#"+spanid+" .ctokbtnimg1").css("display","block");
                $('.tc_inner[data-id="'+spanid+'"]').attr("class","tc_inner clicked");
            }
        }
        $("#allcitypage").css("height",he-40);
        $("#ctchoicepage").css("display","block");
        $("#page_wrapper").css("display","none");
        $("#choicecitybox").css("display","block");
    });
    var hasharr={};//保存第一个首字母的位置
    //加载城市列表
    for(var c1=0;c1<citylist.length;c1++){
        var pinyinid=pinyin.getFullChars(citylist[c1].name).toLowerCase();
        $("#"+citylist[c1].pinyin[0]+" .box").append("<span class='tc_inner' id='"+pinyinid+"'>"+citylist[c1].name+"<div class='rt ctokbtn'> <img src='img/hook-no.png' class='ctokbtnimg2' style='display: block'/> <img src='img/hook01.png' class='ctokbtnimg1' style='display: none'/> </div> </span> <div class='tc_stroke'></div>");
    }
    hasharr.A=0; //hash。A不是0 更改
    for(var key in hasharr){
        $("div.listtitle").eq(hasharr[key]).css("display","block");
    }
    //var choicenum=0;//城市已经选择的个数
    $("li.ctlist span.tc_inner").click(function(e){//列表点击
        var word="";
        var s1;
        var spid="";
        if(e.target.nodeName==="IMG"){

            word=e.target.parentNode.parentNode.innerHTML.match(/[\u4e00-\u9fa5]+/)[0];
            s1=e.target.parentNode.parentNode.getElementsByTagName("img");
            spid="s"+e.target.parentNode.parentNode.id;
        }else{
            word=e.target.innerHTML.match(/[\u4e00-\u9fa5]+/)[0];
            if(e.target.id){
                console.log("有ID："+e.target.id);
                spid="s"+e.target.id;
                s1=e.target.getElementsByTagName("img");

            }
            else if(e.target.dataset.id){
                console.log("有data:"+e.target.dataset.id);
                spid="s"+e.target.dataset.id;
                s1=document.getElementById(e.target.dataset.id).getElementsByTagName("img");

            }

        }

        if(mychoicecityclick===1){
            $(".myctywords span").remove();//所在城市（编辑主页展示）
            $(".myctywords").append("<span id='s"+spid+"'>"+word+"</span>");
            $("#page_wrapper").css("display","block");
            $("#ctchoicepage").css("display","none");
            $(".ctokbtnimg2").css("display","block");
            $("#ctfinish").css("display","block");
            $("#choicecitybox").css("display","block");
            mychoicecityclick=0;
            allmychoicecityclick=0;
        }else{
            if(s1[0].style.display==="block"){
                if(choicenum<3){
                    s1[0].style.display="none";
                    s1[1].style.display="block";
                    choicenum++;

                    $('.tc_inner[data-id="'+spid.replace(/^s/,"")+'"]').attr("class","tc_inner clicked");
                    $("#choicecitybox").append("<span id='"+spid+"'>"+word+"</span>")
                }
            }else if(s1[0].style.display==="none"){
                s1[0].style.display="block";
                s1[1].style.display="none";
                var addspan=document.getElementsByTagName("span");
                for(var i=0;i<addspan.length;i++){
                    addspan[i].index=i;

                    if(addspan[i].innerHTML.match(/[\u4e00-\u9fa5]+/)[0]===word){
                        var spanname="span#"+spid;
                        $('.tc_inner[data-id="'+spid.replace(/^s/,"")+'"]').attr("class","tc_inner");
                        $("span#"+spid).remove();
                        choicenum--;
                        break;
                    }else{
                        console.log("没有找到span")
                    }
                }
            }
        }
    });
    var englishbtn=document.querySelectorAll(".rightnav div");//导航条跳转
    var tonum=0;
    for(var en=0;en<englishbtn.length;en++){
        englishbtn[en].onclick=function(e){
            location.href="#"+e.target.innerHTML;
            history.go(-1);
            //$(document).scrollTop();
            if(mychoicecityclick===1){
                $(document).scrollTop($(document).scrollTop()-104);
            }else{
                $(document).scrollTop($(document).scrollTop()-142);
            }
        }
    }
    //搜索跳转
    $("#csearchbtn").click(function(){
        var word=$("#csearchinput").val();
        var allcitylist=document.getElementsByClassName("tc_inner");
        for(var i=0;i<allcitylist.length;i++){
            var listinner=allcitylist[i].innerHTML.match(/[\u4e00-\u9fa5]+/)[0];
            if(listinner===word){
                var pinyinid=pinyin.getFullChars(word).toLowerCase();
                location.href="#"+pinyinid;
                if(mychoicecityclick===1){
                    $(document).scrollTop($(document).scrollTop()-104);
                }else{
                    $(document).scrollTop($(document).scrollTop()-142);
                }
                break;
            }
        }
    });
    $("#ctfinish").click(function(){ //关闭城市列表
        choicenum=0;
        $("#ctchoicepage").css("display","none");
        $("#page_wrapper").css("display","block");
        var showspan=document.querySelectorAll("#choicecitybox span");
        if(showspan&&showspan.length>0){
            $(".ctywords span").remove();//待过的城市（编辑主页展示）
            for(var i=0;i<showspan.length;i++){
                $(".ctywords").append("<span>"+showspan[i].innerHTML+"</span>");
            }
        }
    });

    ////获取行业列表------------------------------------------------------------------------------------------------------
    //$(".hangyelistbtn").click(function(){
    //    $("#choicepage").css("display","block");
    //    $("#page_wrapper").css("display","none");
    //    $.ajax({
    //        type:"get",
    //        url:joblisturl,
    //        success:function(data){
    //            var tim=0;
    //            for(var i=0;i<data.Data.length;i++){
    //                tim++;
    //                $("#ts_cells").append("<li class='Cell'><span class='tc_inner' id='"+data.Data[i].id+"'>"+data.Data[i].typename+"</span><div class='tc_stroke'></div></li>");
    //                if(tim==data.Data.length){
    //                    if(hyuserdata&&hyuserdata.length>0){
    //                        if(hyuserdata.length>=3){
    //                            for(var r=0;r<3;r++){
    //                                $("#ts_cells #"+hyuserdata[r].id).attr("class","tc_inner isclicked");
    //                            }
    //                        }else{
    //                            for(var r1=0;r1<hyuserdata.length;r1++){
    //                                $("#ts_cells #"+hyuserdata[r1].id).attr("class","tc_inner isclicked");
    //                            }
    //                        }
    //                    }
    //                }
    //            }
    //        }
    //    });
    //});
    ////行业列表项添加点击事件
    //$(".bigbox1").delegate("#choicepage .tc_inner","click",function(event){
    //    if(event.target.className=="tc_inner"){
    //        choicenum++;
    //        event.target.className+=" isclicked";
    //
    //        ///////////////////////////////
    //        if(!document.querySelectorAll("#choicedbox span")[0]||document.querySelectorAll("#choicedbox span").length<3){
    //            $("#choicedbox").append("<span id='"+event.target.id+"' onclick='hydeletaspan(this)'>"+event.target.innerHTML+"<a>×</a></span>");
    //        }else if(document.querySelectorAll("#choicedbox span").length==3){
    //            $("#choicedbox span:first-child").remove();
    //            $("#choicedbox").append("<span id='"+event.target.id+"' onclick='hydeletaspan(this)'>"+event.target.innerHTML+"<a>×</a></span>");
    //            choicenum=3;
    //        }
    //        ///////////////////////////////
    //    }else if(event.target.className=="tc_inner isclicked"){
    //        //alert("已经选择");
    //
    //        event.target.className="tc_inner";
    //        $("#choicedbox span#"+event.target.id).remove();
    //        choicenum--;
    //
    //    }
    //});
    //$("#finish").click(function(){
    //    hyischoiced=[];
    //    for(var r=0;r< $("#choicedbox span").length;r++){
    //        hyischoiced.push({"id":$("#choicedbox span")[r].id,"typename":$("#choicedbox span")[r].innerHTML.match(/[\u4e00-\u9fa5|a-z|A-Z]+/)[0]});
    //
    //    };
    //    $("#choicepage").css("display","none");
    //    $("#page_wrapper").css("display","block");
    //    $(".hangyewords span").remove();
    //    for(var r2=0;r2<hyischoiced.length;r2++){
    //        $(".hangyewords").append("<span>"+hyischoiced[r2].typename+"</span>");
    //        if($(".hangyewords span").length>3){
    //            $(".hangyewords span:first").remove();
    //        }
    //    }
    //});
    ////获取兴趣列表=========================================
    //$(".xingqulistbtn").click(function(){
    //    $("#xqchoicepage").css("display","block");
    //    $("#page_wrapper").css("display","none");
    //    $.ajax({
    //        type:"get",
    //        url:hobbylisturl,
    //        success:function(data){
    //            var tim=0;
    //            for(var i=0;i<data.Data.length;i++){
    //                tim++;
    //                $("#xqts_cells").append("<li class='Cell'><span class='tc_inner' id='"+data.Data[i].id+"'>"+data.Data[i].typename+"</span><div class='tc_stroke'></div></li>");
    //                //已经选择的 改CLASS
    //                if(tim==data.Data.length){
    //                    if(xquserdata&&xquserdata.length>0){
    //                        if(xquserdata.length>=3){
    //                            for(var r=0;r<3;r++){
    //                                $("#xqts_cells #"+xquserdata[r].id).attr("class","tc_inner isclicked");
    //                            }
    //                        }else{
    //                            for(var r1=0;r1<xquserdata.length;r1++){
    //                                $("#xqts_cells #"+xquserdata[r1].id).attr("class","tc_inner isclicked");
    //                            }
    //                        }
    //                    }
    //                }
    //            }
    //        }
    //    });
    //});
    ////兴趣列表项添加点击事件
    //$(".bigbox2").delegate("#xqchoicepage .tc_inner","click",function(event){
    //    if(event.target.className=="tc_inner"){
    //        //xqchoicenum++;
    //        event.target.className+=" isclicked";
    //        if(!document.querySelectorAll("#xqchoicedbox span")[0]||document.querySelectorAll("#xqchoicedbox span").length<3){
    //            $("#xqchoicedbox").append("<span id='"+event.target.id+"' onclick='xqdeletaspan(this)'>"+event.target.innerHTML+"<a>×</a></span>");
    //        }else if(document.querySelectorAll("#xqchoicedbox span").length==3){
    //            $("#xqchoicedbox span:first-child").remove();
    //            $("#xqchoicedbox").append("<span id='"+event.target.id+"' onclick='xqdeletaspan(this)'>"+event.target.innerHTML+"<a>×</a></span>");
    //            xqchoicenum=3;
    //        }
    //    }else if(event.target.className=="tc_inner isclicked"){
    //        event.target.className="tc_inner";
    //        $("#xqchoicedbox span#"+event.target.id).remove();
    //        xqchoicenum--;
    //    }
    //});
    //$("#xqfinish").click(function(){
    //    xqischoiced=[];
    //    for(var i=0;i< $("#xqchoicedbox span").length;i++){
    //        xqischoiced.push({"id":$("#xqchoicedbox span")[i].id,"typename":$("#xqchoicedbox span")[i].innerHTML.match(/[\u4e00-\u9fa5|a-z|A-Z]+/)[0]});
    //    };
    //    $("#xqchoicepage").css("display","none");
    //    $("#page_wrapper").css("display","block");
    //    $(".xingquwords span").remove();
    //    for(var r=0;r<xqischoiced.length;r++){
    //        $(".xingquwords").append("<span>"+xqischoiced[r].typename+"</span>");
    //        if($(".xingquwords>span").length>3){
    //            $(".xingquwords>span:first-child").remove();
    //        }
    //    }
    //});
    ////我常看的新闻==========================================
    //$(".alwaysseelistbtn").click(function(){
    //    $("#alwayschoicepage").css("display","block");
    //    $("#page_wrapper").css("display","none");
    //    $.ajax({
    //        type:"get",
    //        url:zonghenewsurl,
    //        success:function(data){
    //            var tim=0;
    //            for(var i=0;i<data.Data.length;i++){
    //                tim++;
    //                $("#alwaysts_cells").append("<li class='Cell'><span class='tc_inner' id='"+data.Data[i].id+"'>"+data.Data[i].typename+"</span><div class='tc_stroke'></div></li>");
    //                //已经选择的 改CLASS
    //                if(tim==data.Data.length){
    //                    if(xwuserdata&&xwuserdata.length>0){
    //                        if(xwuserdata.length>=3){
    //                            for(var r=0;r<3;r++){
    //                                $("#alwaysts_cells #"+xwuserdata[r].id).attr("class","tc_inner isclicked");
    //                            }
    //                        }else{
    //                            for(var r1=0;r1<xwuserdata.length;r1++){
    //                                $("#alwaysts_cells #"+xwuserdata[r1].id).attr("class","tc_inner isclicked");
    //                            }
    //                        }
    //                    }
    //                }
    //            }
    //        }
    //    });
    //});
    ////常看新闻添加点击事件
    //$(".bigbox1").delegate("#alwayschoicepage .tc_inner","click",function(event){
    //    if(event.target.className=="tc_inner"){
    //        //alwayschoicenum++;
    //        event.target.className+=" isclicked";
    //        if(!document.querySelectorAll("#alwayschoicedbox span")[0]||document.querySelectorAll("#alwayschoicedbox span").length<3){
    //
    //            $("#alwayschoicedbox").append("<span id='"+event.target.id+"' onclick='aldeletaspan(this)'>"+event.target.innerHTML+"<a>×</a></span>");
    //
    //        }else if(document.querySelectorAll("#alwayschoicedbox span").length==3){
    //            $("#alwayschoicedbox span:first-child").remove();
    //            $("#alwayschoicedbox").append("<span id='"+event.target.id+"' onclick='aldeletaspan(this)'>"+event.target.innerHTML+"<a>×</a></span>");
    //            alwayschoicenum=3;
    //        }
    //    }else if(event.target.className=="tc_inner isclicked"){
    //        event.target.className="tc_inner";
    //        $("#alwayschoicedbox span#"+event.target.id).remove();
    //        alwayschoicenum--;
    //    }
    //});
    //$("#alwaysfinish").click(function(){
    //    alwaysnews=[];
    //    for(var r=0;r< $("#alwayschoicedbox span").length;r++){
    //        alwaysnews.push({"id":$("#alwayschoicedbox span")[r].id,"typename":$("#alwayschoicedbox span")[r].innerHTML.match(/[\u4e00-\u9fa5|a-z|A-Z]+/)[0]});
    //
    //    };
    //    $("#alwayschoicepage").css("display","none");
    //    $("#page_wrapper").css("display","block");
    //    $(".alwayswords span").remove();
    //    for(var r2=0;r2<alwaysnews.length;r2++){
    //        $(".alwayswords").append("<span>"+alwaysnews[r2].typename+"</span>");
    //        if($(".alwayswords span").length>3){
    //            $(".alwayswords span:first").remove();
    //        }
    //    }
    //});

    //选择性别
    $("#choicesex").click(function(){
        if($("#sexbox1").css("display")=="block"){
            $("#sexbox1").css("display","none");
            $("#sexbox2").css("display","block");
            sex=0;
        }else if($("#sexbox1").css("display")=="none"){
            $("#sexbox1").css("display","block");
            $("#sexbox2").css("display","none");
            sex=1;
        }
    });
    //上传图片
    var img_area = document.getElementById("upload-img");
    //=======图片压缩上传=======================
    //==================================
    if ( typeof(FileReader) === 'undefined' ){
        alert("抱歉，你的浏览器不支持 FileReader，请使用现代浏览器操作！");
    } else {
        //addimgbtn.addEventListener( 'change',createimg,false );
        //新
        touxiangbtn.addEventListener('change', readFile, false);
    };
    //==================================
    //$(document).ready(function(e) {
    //    $('#touxiangbtn').localResizeIMG({
    //        width: 180,
    //        quality: 1,
    //        before:function(that,blob,file){$("#imgchoicepage img").attr("src",blob);},
    //        success: function (result) {
    //            submitData=result.base64;
    //            $("#page_wrapper").css("display","none");
    //            $("#imgchoicepage").css("display","block");
    //            $('#element_id').Jcrop({
    //                allowSelect: true,
    //                baseClass: 'jcrop',
    //                minSize:[100,100],
    //                aspectRatio:0.9,
    //                onSelect:function(d){
    //                    coordinateX=Math.round((d.x/avaW)*100)/100;
    //                    coordinateY=Math.round((d.y/avaH)*100)/100;
    //                    coordinateH=Math.round((d.h/avaH)*100)/100;
    //                    coordinateW=Math.round((d.w/avaW)*100)/100;
    //                }
    //            }, function() {
    //                jcropApi = this;
    //            });
    //            //上传图片
    //            $("#imgfinish").click(function(){
    //                $.ajax({
    //                    type: "POST",
    //                    url: cutimgurl,
    //                    data: {"base64":submitData,"type":".jpg","flag":1,"x":coordinateX,"y":coordinateY,"h":coordinateH,"w":coordinateW},
    //                    dataType:"json",
    //                    success: function(data){
    //                        cansendimg="yes";
    //                        userAva=data.Data;
    //                        coordinateX=0;
    //                        coordinateY=0;
    //                        coordinateH=1;
    //                        coordinateW=1;
    //                        $("#imgchoicepage").css("display","none");
    //                        $("#page_wrapper").css("display","block");
    //                        img_area.innerHTML = '<img src="'+imgurl+data.Data+'" alt="" onload="showloadimg(this)" style="display:none;"/>';
    //                        jcropApi=null;
    //                        submitData=null;
    //                    }
    //                });
    //            });
    //        }
    //    });
    //});

    //图片返回
    $("#chimggoback").click(function(){
        $("#imgchoicepage").css("display","none");
        $("#page_wrapper").css("display","block");
    });

    //向服务器提交数据
    $("#savechange").click(function(){
        var nick=$("#nick_name").val(); //昵称
        if(!/^[\u4E00-\u9FA5a-zA-Z0-9_]{1,7}$/.test(nick)){
            $("#nokeywordalert").css("display","block");
            $("#nokeywordalert .word").html("昵称仅支持中英文、数字和下划线！");
        }
        else if(testRanking()){
            if(!/^[\u4E00-\u9FA5a-zA-Z0-9_]{1,7}$/.test(nick)){
                $("#nokeywordalert").css("display","block");
                $("#nokeywordalert .word").html("昵称仅支持中英文、数字和下划线！");
            }
            else{
                var education=$(".eduwords").html();  //教育
                var cities=[];
                if(document.querySelectorAll(".ctywords span").length>0){
                    var showspan=document.querySelectorAll(".ctywords span");
                    for(var r=0;r<showspan.length;r++){cities.push(showspan[r].innerHTML);}
                }
                cities=cities.join(" ");
                var city="";
                if(document.querySelectorAll(".myctywords span").length>0){
                    var showmyspan=document.querySelector(".myctywords span");
                    if(document.querySelector(".myctywords span").innerHTML){city=document.querySelector(".myctywords span").innerHTML;}
                }
                var sign=$("#personalword").val();  //个性签名
                var hobby="";//兴趣ID
                var job="";  //行业ID
                var news=""; //新闻ID
                var cover=$("#mylabel").val();//自定义标签
                //行业兴趣反了
                for(var i=0;i<hyischoiced.length;i++){job+=hyischoiced[i].id+",";};
                for(var r=0;r<xqischoiced.length;r++){hobby+=xqischoiced[r].id+",";};
                for(var t=0;t<alwaysnews.length;t++){news+=alwaysnews[t].id+",";};
                hobby=hobby.substring(0,hobby.length-1);
                job=job.substring(0,job.length-1);
                var administrationNum=0;
                choiceAdministration?administrationNum=$("#manageRank").val():'';
                var  jobId=0;
                if(choiceAdministration){ jobId=1};
                if(choiceSkill){jobId=2};
                if(choiceAdministration&&choiceSkill){ jobId=3};
                var newprofessionName=professionName.join(",");
                var numCompanyRank=parseInt($("#companyRank").val());
                var PuluUser={
                    "realName":"",
                    "cover":"",
                    "city":city,
                    "companyRank":numCompanyRank,
                    "education":education,
                    "jobId":jobId,
                    "manageRank":parseInt(administrationNum),
                    "newJobs":newprofessionName,
                    "nick":nick,
                    "sex":sex,
                    "sign":sign,
                    "userAva":userAva,
                    "userId":id,
                    "visitedcity":cities
                };
                if(TechParam.length===0){TechParam="[]";}
                $.ajax({
                    type: "post",
                    url: updateuserurl,
                    data:{"user":PuluUser,"TechKeyWordRanks":TechParam},
                    success:function(data){
                        if(data.Code=="TRUE"){window.location.href="setpageInfo.html";}else if(data.Code=="FALSE"){$("#nokeywordalert").css("display","block");}
                    }
                })
            }
        }
    })
});
document.onkeydown=function(event){
    var e = event || window.event || arguments.callee.caller.arguments[0];
    if(e && e.keyCode==13&&ctchoicepage.style.display=="block"){
        var word=$("#csearchinput").val();
        var allcitylist=document.querySelectorAll(".box .tc_inner");
        for(var i=0;i<allcitylist.length;i++){
            var listinner=allcitylist[i].innerHTML.match(/[\u4e00-\u9fa5]+/)[0];
            if(word===listinner){
                var pinyinid=pinyin.getFullChars(word).toLowerCase();
                location.href="#"+pinyinid;
                if(allmychoicecityclick===1){
                    location.href="#";
                    $(document).scrollTop($(document).scrollTop()+104);
                }else{
                    location.href="#";
                    $(document).scrollTop($(document).scrollTop());
                }
                break;
            }
        }
    }
};
$("#csearchinput").bind("input propertypechange",function() {
    var word=$("#csearchinput").val();
    var len=word.length;
    var allcitylist=document.querySelectorAll(".box .tc_inner");
    for(var i=0;i<allcitylist.length;i++){
        var listinner=allcitylist[i].innerHTML.match(/[\u4e00-\u9fa5]+/)[0];
        var listinner2=allcitylist[i].innerHTML.match(/[\u4e00-\u9fa5]+/)[0].substr(0,len);
        if(word===listinner2){
            var pinyinid=pinyin.getFullChars(listinner).toLowerCase();
            location.href="#"+pinyinid;
            if(allmychoicecityclick===1){
                console.log($(document).scrollTop()-104);
                location.href="#";
                $(document).scrollTop($(document).scrollTop()+104);
            }else{
                location.href="#";
                console.log($(document).scrollTop()-142);
                $(document).scrollTop($(document).scrollTop());
            }
            break;
        }
    }
});
//签名输入框操作
$('#personalword').bind('input propertypechange',function() {
    if($("#personalword").val().length>30){$("#personalword").val(($("#personalword").val()).substr(0,30));}
});
//标签
$('#mylabel').bind('input propertychange', function() {
    if($("#mylabel").val().length>10){$("#mylabel").val(($("#mylabel").val()).substr(0,10));}
});